package com.model;

// Generated 2013-8-25 14:56:38 by Hibernate Tools 3.6.0

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Article generated by hbm2java
 */
@Entity
@Table(name = "article")
public class Article implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4376708842564733431L;

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	private Integer id;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id", nullable = false)
	private User user;

	@Column(name = "title", nullable = false, length = 128)
	private String title;

	@Column(name = "content", length = 65535)
	private String content;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_at", nullable = false, length = 19)
	private Date createAt;

	@Column(name = "comments_num", nullable = false)
	private int commentsNum;

	@Column(name = "favor_num", nullable = false)
	private int favorNum;

	@Column(name = "agree_num", nullable = false)
	private int agreeNum;

	@Column(name = "disagree_num", nullable = false)
	private int disagreeNum;

	@Column(name = "collect_num", nullable = false)
	private int collectNum;

	@Column(name = "is_public", nullable = false)
	private int isPublic;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "article")
	private Set<ArticleComment> articleComments = new HashSet<ArticleComment>(0);

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "article_tag", joinColumns = { @JoinColumn(name = "article_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "tag_id", nullable = false, updatable = false) })
	private Set<Tag> tags = new HashSet<Tag>(0);

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "article")
	private Set<ArticleAction> articleActions = new HashSet<ArticleAction>(0);
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "alliance_id", nullable = true)
	private Alliance alliance;
	
	@Column(name = "title_image",  length = 255)
	private String titleImage;
	
	@Column(name = "description",  length = 1024)
	private String description;

	public Article() {
	}

	public Article(User user, String title, Date createAt, int commentsNum, int favorNum) {
		this.user = user;
		this.title = title;
		this.createAt = createAt;
		this.commentsNum = commentsNum;
		this.favorNum = favorNum;
	}

	public Article(User user, String title, String content, Date createAt, int commentsNum,
			int favorNum, Set<ArticleComment> articleComments, Set<Tag> tags,
			Set<ArticleAction> articleActions) {
		this.user = user;
		this.title = title;
		this.content = content;
		this.createAt = createAt;
		this.commentsNum = commentsNum;
		this.favorNum = favorNum;
		this.articleComments = articleComments;
		this.tags = tags;
		this.articleActions = articleActions;
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getCreateAt() {
		return this.createAt;
	}

	public void setCreateAt(Date createAt) {
		this.createAt = createAt;
	}

	public int getCommentsNum() {
		return this.commentsNum;
	}

	public void setCommentsNum(int commentsNum) {
		this.commentsNum = commentsNum;
	}

	public int getFavorNum() {
		return this.favorNum;
	}

	public void setFavorNum(int favorNum) {
		this.favorNum = favorNum;
	}

	public Set<ArticleComment> getArticleComments() {
		return this.articleComments;
	}

	public void setArticleComments(Set<ArticleComment> articleComments) {
		this.articleComments = articleComments;
	}

	public Set<Tag> getTags() {
		return this.tags;
	}

	public void setTags(Set<Tag> tags) {
		this.tags = tags;
	}

	public Set<ArticleAction> getArticleActions() {
		return this.articleActions;
	}

	public void setArticleActions(Set<ArticleAction> articleActions) {
		this.articleActions = articleActions;
	}

	public int getIsPublic() {
		return isPublic;
	}

	public void setIsPublic(int isPublic) {
		this.isPublic = isPublic;
	}

	public int getAgreeNum() {
		return agreeNum;
	}

	public void setAgreeNum(int agreeNum) {
		this.agreeNum = agreeNum;
	}

	public int getDisagreeNum() {
		return disagreeNum;
	}

	public void setDisagreeNum(int disagreeNum) {
		this.disagreeNum = disagreeNum;
	}

	public int getCollectNum() {
		return collectNum;
	}

	public void setCollectNum(int collectNum) {
		this.collectNum = collectNum;
	}

	public Alliance getAlliance() {
		return alliance;
	}

	public void setAlliance(Alliance alliance) {
		this.alliance = alliance;
	}

	public String getTitleImage() {
		return titleImage;
	}

	public void setTitleImage(String titleImage) {
		this.titleImage = titleImage;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

}
